<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
	#h1{
		text-align: center;
	}
	#t1{
		text-align: center;
		margin: 0 auto;
		width: 600px;
		border: 1px solid black;
		border-collapse: collapse;
	}
	#t1 td,#t1 th{
		border: 1px solid black;
		line-height: 30px;
	}
	#t1 tr:nth-child(1) {
		background-color: rgb(232, 242, 254);
	}
	
	#t1 tr:nth-child(even) {
		background-color: rgb(225, 230, 246);
	}
	#t1 tr:hover {
	   background-color: yellow;
	}
	#d1{
		width: 600px;
		margin: 0 auto;
		text-align: right;
	}
</style>
<script src="${pageContext.request.contextPath }/webjars/jquery/3.5.1/jquery.min.js"></script>
<script>
	$(function(){
		$(".delete").click(function(){
			if(confirm("确定删除吗？")){
				$("#f1").attr("action",this.href).submit();
			}
			return false;
		});
	});
</script>
</head>
<body>

		<h1 id="h1">商品列表</h1>
		<div id="d1">
			<a href="${pageContext.request.contextPath }/goods/add">新增</a>
		</div>
		<table id="t1">
			<tr>
				<th>商品ID</th>
				<th>商品编号</th>
				<th>商品名称</th>
				<th>商品价格</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${goodsList }" var="goods">
				<tr>
					<td>${goods.id }</td>
					<td>${goods.goodsCode }</td>
					<td>${goods.goodsName }</td>
					<td>${goods.goodsPrice }</td>
					<td>
						<a href="${pageContext.request.contextPath }/goods/${goods.id}">修改</a>
						|
						<a class="delete" href="${pageContext.request.contextPath }/goods/${goods.id}">删除</a>
					</td>
				</tr>
			</c:forEach>
		</table>
		<form id="f1" method="post">
			<input type="hidden" name="_method" value="delete">
		</form>
		
</body>
</html>